﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using MVCDemo.Models;

namespace MVCDemo.Data
{
    public class DataInitlizer : DropCreateDatabaseIfModelChanges<MVCDemoDb>
    {
        protected override void Seed(MVCDemoDb db)
        {
            db.Users.AddRange(new List<Users>
            {
                new Users
                {
                    Username="用户1",
                    Password="123"
                },new Users
                {
                    Username="用户2",
                    Password="123"
                },new Users
                {
                    Username="用户3",
                    Password="123"
                },new Users
                {
                    Username="用户4",
                    Password="123"
                },new Users
                {
                    Username="用户5",
                    Password="123"
                },new Users
                {
                    Username="用户5",
                    Password="123"
                }
            });

            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                    FromUserId=1,
                    Content="我是第一个用上微说说的人"
                },new Messages
                {
                    FromUserId=2,
                    Content="嘻嘻我第二"
                },new Messages
                {
                    FromUserId=3,
                    Content="哦豁俺第三"
                },new Messages
                {
                    FromUserId=4,
                    Content="我我觉得这个还不错"
                },new Messages
                {
                    FromUserId=5,
                    Content="害，感觉一般般"
                },new Messages
                {
                    FromUserId=6,
                    Content="确实做的不怎么样"
                }
            });

            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    FromUserId=1,
                    MsgId=3,
                    Comment="那好吧"
                },new Comments
                {
                    FromUserId=2,
                    MsgId=4,
                    Comment="今天考试咯"
                },new Comments
                {
                    FromUserId=4,
                    MsgId=1,
                    Comment="痛悼袁隆平"
                },new Comments
                {
                    FromUserId=2,
                    MsgId=4,
                    Comment="好想吃炸鸡"
                },new Comments
                {
                    FromUserId=3,
                    MsgId=3,
                    Comment="让我们一起摇摆"
                },new Comments
                {
                    FromUserId=6,
                    MsgId=2,
                    Comment="神马是快乐星球"
                },
            });
            db.SaveChanges();
            base.Seed(db);
        }
    }
}